﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;

namespace School.Pages.Admission.Reports
{
    public partial class showstudentsDetailsReport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ObjectDataSource1.FilterExpression += "1 = 1 ";
                if (!string.IsNullOrEmpty(Session["stcampus"].ToString()))
                    ObjectDataSource1.FilterExpression += string.Format(" And Campus_Id = {0}", Session["stcampus"].ToString());

                if (!string.IsNullOrEmpty(Session["stcertificate"].ToString()))
                    ObjectDataSource1.FilterExpression += string.Format(" And Certificate_Id = {0}", Session["stcertificate"].ToString());

                if (!string.IsNullOrEmpty(Session["ststage"].ToString()))
                    ObjectDataSource1.FilterExpression += string.Format(" And Stage_Id = {0}", Session["ststage"].ToString());

                if (!string.IsNullOrEmpty(Session["stgrade"].ToString()))
                    ObjectDataSource1.FilterExpression += string.Format(" And Grade_ID = {0}", Session["stgrade"].ToString());

                if(!string.IsNullOrEmpty(Session["stname"].ToString()))
                    ObjectDataSource1.FilterExpression += string.Format(" And FullName Like '%{0}%'", Session["stname"].ToString());

                if (!string.IsNullOrEmpty(Session["stFileNumber"].ToString()))
                    ObjectDataSource1.FilterExpression += string.Format(" And FileNumber = {0}", Session["stFileNumber"].ToString());

                if (!string.IsNullOrEmpty(Session["stReistrationNumber"].ToString()))
                    ObjectDataSource1.FilterExpression += string.Format(" And RegistrationNumber = {0}", Session["stReistrationNumber"].ToString());

               
                bool [] visible = new bool[16];
                visible = (bool[])Session["visibles"];
                ReportParameter[] param = new ReportParameter[16];
                param[0] = new ReportParameter("NameVisible", visible[0].ToString(), true);
                param[1] = new ReportParameter("StudentNoVisible", visible[1].ToString(), true);
                param[2] = new ReportParameter("BirthDayVisible", visible[2].ToString(), true);
                param[3] = new ReportParameter("IdNoVisible", visible[3].ToString(), true);
                param[4] = new ReportParameter("PassportVisible", visible[4].ToString(), true);
                param[5] = new ReportParameter("GenderVisible", visible[5].ToString(), true);
                param[6] = new ReportParameter("FatherjobVisible", visible[6].ToString(), true);
                param[7] = new ReportParameter("FatherspecialVisible", visible[7].ToString(), true);
                param[8] = new ReportParameter("FatherQualiVisible", visible[8].ToString(), true);
                param[9] = new ReportParameter("MotherJobVisible", visible[9].ToString(), true);
                param[10] = new ReportParameter("MotherQualiVisible", visible[10].ToString(), true);
                param[11] = new ReportParameter("ReligionVisible", visible[11].ToString(), true);
                param[12] = new ReportParameter("FileNo", visible[12].ToString(), true);
                param[13] = new ReportParameter("MotherPointOfGrd", visible[13].ToString(), true);
                param[14] = new ReportParameter("MotherSpec", visible[14].ToString(), true);
                param[15] = new ReportParameter("FatherPointOfGrd", visible[15].ToString(), true);

              
                this.ReportViewer1.LocalReport.SetParameters(param);
               
                ReportViewer1.LocalReport.Refresh();
            }
        }      
      
    }
}